package com.wealth.scsj.p_app.view.fragment;


import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.wealth.scsj.p_app.R;
import com.wealth.scsj.p_app.adapter.OrderIndexAdapter;
import com.wealth.scsj.p_app.bean.OrderIndexBean;
import com.wealth.scsj.p_app.utils.SkipUtils;

import java.util.ArrayList;
import java.util.List;

import es.dmoral.toasty.Toasty;

/**
 * 待抢单
 */
public class WaitFragment extends BaseFragment {

    private RecyclerView wait_rv;
    private List<OrderIndexBean> orderIndexBeanList;
    private OrderIndexAdapter adapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View inflate = inflater.inflate(R.layout.fragment_wait, null);
        initView(inflate,null);
        initData();
        return inflate;
    }


    @Override
    protected void initView(View view, Bundle savedInstanceState) {
        wait_rv = view.findViewById(R.id.wait_rv);
        wait_rv.setLayoutManager(new LinearLayoutManager(getHoldingActivity()));
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {
        orderIndexBeanList = new ArrayList<>();
        for (int i = 0; i < 6; i++) {
            orderIndexBeanList.add(new OrderIndexBean("fff", "fff", "fff", "fff", "fff", "fff", "fff", "fff"));
        }
        adapter = new OrderIndexAdapter(orderIndexBeanList);
        wait_rv.setAdapter(adapter);
        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                view.findViewById(R.id.order_detail_tv).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        SkipUtils.toOrderDetail(getHoldingActivity());
                    }
                });

                view.findViewById(R.id.contact_tv).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Toasty.info(getHoldingActivity(), "点击了").show();
                    }
                });
                view.findViewById(R.id.make_sure_tv).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Toasty.info(getHoldingActivity(), "点击了").show();
                    }
                });
            }
        });
    }

    @Override
    protected int getLayoutId() {
        return 0;
    }

}
